/**
 * *js-api 认证 不对外暴露
 */
let cjcAuth = function(auth, that) {
    let jsSession = sessionStorage.getItem('jsSession')
    that.cjcLog('cjcAuth() start')
    let resultData = {
        msg: '',
        status: ''
    }
    try {
        that.cjcLog('authCheckApp start')
        // 代码处理...
        if (jsSession === undefined || jsSession === '' || jsSession === null) {
            that.cjcLog('not logion cjcAuth() fail')
            resultData.status = -1
            resultData.msg = '未登录'
            that.cjcLog('cjcAuth:' + that.printObject(resultData))
            auth.fail(resultData)
            return
        }
        console.log('jsSession---', jsSession)
        window.WebViewJavascriptBridge.callHandler('authCheckApp', {
            'session': jsSession
        }, function(response) {
            // 方法执行成功
            that.cjcLog('api/authCheckApp end')
            // 确认至json对象
            that.cjcLog('response:' + that.printObject(response))
            if (typeof response === 'string') {
                response = JSON.parse(response)
            }
            if (response.status === 0) {
                that.cjcLog('cjcAuth() success')
                resultData.status = 0
                resultData.msg = '认证成功'
                that.cjcLog('cjcAuth:' + that.printObject(resultData))
                auth.success(resultData)
            } else {
                that.cjcLog('cjcAuth() fail')
                resultData.stutas = response.status
                resultData.msg = response.msg
                that.cjcLog('cjcAuth:' + that.printObject(resultData))
                auth.fail(resultData)
            }
        })
    } catch (e) {
        that.cjcLog('cjcAuth() fail')
        resultData.stutas = 4
        resultData.msg = '认证失败'
        that.cjcLog('cjcAuth:', resultData)
        auth.fail(resultData)
    }
}
export {
    cjcAuth
}
